import 'package:flutter/material.dart';
import 'package:flutter_ncsjqz_getx/constant/constant.dart';
import 'package:flutter_ncsjqz_getx/widget/ink_widget.dart';
import 'package:get/get.dart';

class BottomNavModel{
  String? label;
  String? img;// 选中
  String? unImg; // 未选中
  Color? color;// 选中
  Color? unColor;// 未选中

  BottomNavModel({this.label, this.img, this.unImg, this.color, this.unColor});
}

/// todo：底部菜单 样式：选择图、未选中图
bottomNavWidget({
  required int currentIndex,
  required Function(int) onTap,
  required List<BottomNavModel> menuData,
  Color? bgColor,
}){
  return Container(
      width: Get.width,
      // 判断部分手机 底部存在虚拟按键或者小黑条
      height: Get.bottomBarHeight > 0.0 ? Get.bottomBarHeight+1 : 55,
      color: bgColor,
      decoration: BoxDecoration(
        border: Border(top: BorderSide(color: Color(0xE0E0E0FF),width: 0.5))
      ),
      child: SafeArea(
        child: Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: List.generate(menuData.length, (index){
            // Material->Ink 设置点击水波纹
            return Material(
              color: Colors.transparent,
              child: Ink(
                child: InkWell(
                  onTap: (){
                    onTap(index);
                  },
                  child: Stack(
                    children: [
                      Container(
                        width: Get.width / menuData.length,
                        padding: EdgeInsets.all(8),
                        child: Column(
                          mainAxisAlignment: MainAxisAlignment.spaceBetween,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Image.asset("${index != currentIndex ? menuData[index].unImg : menuData[index].img}",width: 22,height: 22,),
                            Expanded(child: Text("${menuData[index].label ?? ''}",maxLines: 1,overflow: TextOverflow.ellipsis,style: TextStyle(fontSize: 13,color: index != currentIndex ? menuData[index].unColor : menuData[index].color),),)
                          ],
                        ),
                      ),
                      Positioned(
                        right: 15,
                        top: 3,
                        child: Constant.msgCount! == 0 ?SizedBox() : ClipRRect(
                          borderRadius: BorderRadius.circular(20),
                          child: Container(
                            width: 20,
                            height: 20,
                            alignment: Alignment.center,
                            color: index!=0 ?Colors.transparent: Colors.red,
                            child: InkWidget.text(Constant.msgCount,color: Colors.white),
                          ),
                        ),
                      ),
                    ],
                  ),
                ),
              ),
            );
          }),
        ),
      ),
  );
}